package com.blueberriesteam.kg.parser;

import com.blueberriesteam.kg.entity.Queries;
import com.blueberriesteam.kg.entity.Comment;
import org.w3c.dom.NodeList;

import java.util.ArrayList;
import java.util.List;

public class ParseComment {




    public List<Comment> getComments(String link) {
        Connect.setLink(link);
        final NodeList nodeDate = Connect.getPage(Queries.COMMENT_DATE);
        final NodeList nodeUser = Connect.getPage(Queries.COMMENT_USER);
        final NodeList nodeValue = Connect.getPage(Queries.COMMENT_VALUE);
        List<Comment> comments = new ArrayList<Comment>();
        Comment comment = new Comment();
        for (int i = 0; i < nodeValue.getLength(); i++) {
            comment.setString(nodeValue.item(i).getFirstChild().getNodeValue());
            comment.setDate(nodeDate.item(i).getFirstChild().getNodeValue());
            comment.setUser(nodeUser.item(i).getFirstChild().getNodeValue());
            comments.add(comment);

        }



        return comments;
    }


}
